<template>
  <div class="header-container">
    <div class="l-content">
      <el-button @click="handleMenu" icon="Fold" size="small"></el-button>
      <!-- 面包屑 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item v-for="item in tags" :key="item.menuName" :to="{ path: item.routerPath }">{{ item.menuName }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown>
                <span class="el-dropdown-link">
                    <img class="user" src="../assets/images/user.png" alt="">
                </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人信息</el-dropdown-item>
            <el-dropdown-item @click="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import {mapState,useStore } from 'vuex'
import {removeToken} from '../utils/cookies.js'
import {computed, ref, watch} from "vue";
import {useRouter} from "vue-router";

const store = useStore();
const router = useRouter();

// 定义方法
const handleMenu = () => {
  store.commit('CollapseMenu');
};

function logout (){
    removeToken();
    router.push('/login');
}
const tags = computed(() => store.state.tab.tabList);
</script>

<style lang="less" scoped>
.header-container {
  background-color: #ffffff;
  border-bottom: 1px solid #d9d7d7;
  height: 60px;

  // 让按钮和头像居中
  display: flex;
  justify-content: space-between;
  align-items: center;
  // 不要紧贴边框
  padding: 0 20px;

    .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;

    .user {
      width: 40px;
      height: 40px;
      // 50%变圆形
      border-radius: 50%;
    }
  }
}

.l-content {
  display: flex;
  // 上下居中
  align-items: center;

  .el-breadcrumb {
    margin-left: 15px;

  }
}
</style>